package Thread;

public class Demo3 {
    public static void main(String[] args) throws InterruptedException {
        Thread th = new Thread(){
            //匿名内部类(且这个类是 Thread 的子类)：
            //且在这个匿名内部类的内部重写了父类的 run 方法
            @Override
            public void run() {
                while (true) {
                    System.out.println("hello thread");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        };
        th.start();
        while(true){
            System.out.println("hello main");
//            Thread.sleep(1000);
        }
    }
}


